#!/bin/bash
# description:　check system load using uptime, every 3 minutes, if greater than 10, restart httpd
# version:	1.0
#

SYS_LOAD=`uptime`
IS_OVERLOAD=`uptime |awk -F "," '{print $4}'|awk -F ":" '{if($2>10){print 1} else {print 0}}'`
# echo $LOADTIME
if [ $IS_OVERLOAD -eq "1" ]; then
    # echo "Restarting server..."
    /usr/bin/logger Restarting HTTPD service due to high load: $SYS_LOAD
    /usr/bin/systemctl restart httpd.service
else
    /usr/bin/logger System load normal: $SYS_LOAD
fi
